package org.example.springbootserver.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@AllArgsConstructor
@NoArgsConstructor
@Data
public class R<T> {
    private T data;
    private String message;
    private int status;//成功为1，失败为0或其他数字

    public static <T> R<T> success(T data) {
        R<T> r=new R<>();
        r.status=1;
        r.data = data;
        return r;
    }

    public static <T> R<T> error(String msg) {
        R<T> r=new R<>();
        r.status=0;
        r.message = msg;
        return r;
    }
}
